package com.cn.action;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;



import com.cn.dao.DoctorDao;
import com.cn.entity.Doctor;

import com.opensymphony.xwork2.Action;

public class DoctorLoginAction implements Action{

    String doctorname;
    String password;
    
    
    
	

		public String getDoctorname() {
		return doctorname;
	}





	public void setDoctorname(String doctorname) {
		this.doctorname = doctorname;
	}





	public String getPassword() {
		return password;
	}





	public void setPassword(String password) {
		this.password = password;
	}





		@Override
		public String execute() throws Exception {
			// TODO Auto-generated method stub
			
			Doctor doc=new Doctor(doctorname, password);
			
			System.out.println(doc.getDoctorname());
			System.out.println(doc.getPassword());
			String sql="login";
			
			
			
			
			if(doc!=null) {
				
				DoctorDao dd=new DoctorDao();
				
				doc=dd.login(doc);
			
			HttpSession session=ServletActionContext.getRequest().getSession();
			
			
			if (doc.getPro()==2){sql="keshi";  session.setAttribute("doctor", doc);                 }
			
			if (doc.getPro()==3){sql="tijian";   session.setAttribute("doctor", doc);                }
			
			if (doc.getPro()==8){sql="success";    session.setAttribute("manager", doc);               }
			}
			
			
			
			return sql;
			
		}
		
		
		}


